var toolBarAjaxPath="http://buy.en.jd.com/Service/OrderToolBarService.aspx";

//获取订单配送信息
function ShowOrderProcess(){
		$.ajax({
			type:"Get",
			url:orderProcessAjaxPath,
			dataType:"jsonp",
			success:function(result){
				if(result.info&&result.info.umsMessages){
					var resultStr="<div class=\"mtt\"><span class=\"q1\">Processing Time</span><span class=\"q2\">Processing Information</span></div><div class=\"mcc\"><ul>";
					var len=result.info.umsMessages.length;
					var temp="";
					for(var i=0;i<len;i++){
						temp=temp+"<li><span class=\"w1\">"+splitDateforMessage(getDateStr(result.info.umsMessages[i].dateUms))+"</span><span class=\"w2\">"+result.info.umsMessages[i].content+"</span></li>";
					}
					resultStr=resultStr+temp+"</ul></div>";
					$("#orderProcessInfo").html(resultStr);
				}
				if(result.info&&result.info.datePayment){
					$("#orderpaymenttime").html(splitDateforProcess(getDateStr(result.info.datePayment)));
				}
				if(result.info&&result.info.dateProcess){
					$("#orderprocesstime").html(splitDateforProcess(getDateStr(result.info.dateProcess)));
				}
				if(result.info&&result.info.dateShopping){
					$("#ordershopingtime").html(splitDateforProcess(getDateStr(result.info.dateShopping)));
				}
				if(result.info.logisticSupplier||result.info.shippingMethod||result.info.shippingId){
					var ls=(result.info.logisticSupplier)?result.info.logisticSupplier:"N/A";
					var sm=(result.info.shippingMethod)?result.info.shippingMethod:"N/A";
					var si=(result.info.shippingId)?result.info.shippingId:"N/A";
					var shipinfo="<div class=\"mtt\"><span class=\"q1\">Logistic supplier</span><span class=\"q2\">shipping method</span><span class=\"q3\">shipping ID</span></div><div class=\"mcc\"><ul><li><span class=\"d1\">"+ls+"</span><span class=\"d2\">"+sm+"</span><span class=\"d3\">"+si+"</span></li></ul></div>";
					$("#orderShipInfo").html(shipinfo);						
				}
			}
		});
}



function getDateStr(time){
	var d=new Date();
	d.setTime(time);
	return d;
}

function splitDateforMessage(date){
	var yyyy=date.getFullYear();
	var MM=(date.getMonth()+1)<10?"0"+(date.getMonth()+1):date.getMonth()+1;
	var dd=date.getDate()<10?"0"+date.getDate():date.getDate();
	var hh=date.getHours()<10?"0"+date.getHours():date.getHours();
	var mm=date.getMinutes()<10?"0"+date.getMinutes():date.getMinutes();
	var ss=date.getSeconds()<10?"0"+date.getSeconds():date.getSeconds();
	return yyyy+"-"+MM+"-"+dd+" "+hh+":"+mm+":"+ss;
}

function splitDateforProcess(date){
	var yyyy=date.getFullYear();
	var MM=(date.getMonth()+1)<10?"0"+(date.getMonth()+1):date.getMonth()+1;
	var dd=date.getDate()<10?"0"+date.getDate():date.getDate();
	var hh=date.getHours()<10?"0"+date.getHours():date.getHours();
	var mm=date.getMinutes()<10?"0"+date.getMinutes():date.getMinutes();
	var ss=date.getSeconds()<10?"0"+date.getSeconds():date.getSeconds();
	return yyyy+"-"+MM+"-"+dd+"<br/>"+hh+":"+mm+":"+ss;
}

function ConfirmDeliver(orderId){
	if(orderId>0){
		if(confirm("Do you acknowledge you have received your order?")){
			$.ajax({
				type:"Get",
				url:toolBarAjaxPath,
				data:{action:"ConfirmDeliver",orderid:orderId},
				dataType:"jsonp",
				success:function(result){
					if(result.html=="确认收货成功"){
						var t=new Date();
						window.location.href="http://order.en.jd.com/normal/list.action?t="+t.getTime();
					}
				}
			})
		}
	}
}